$(function(){
    var cs = getQueryString(href).productid;
    // console.log(cs)
    let product = document.querySelector("#product")
    let str =""
    fetch("http://chst.vip:1234/api/getproduct?productid="+cs)
    .then(body=>body.json())
    .then(res=>{
        // console.log(res)
        res.result.forEach(item => {
            let regExp = /(\/|http)[^>]+\.(jpg|jpeg|png|gif)/g
            let r = item.productImg.match(regExp)
            str += `
                <div class="info">
                    <div class="pic">
                        <img src="${r[0]}" alt="">
                    </div>
                    <div class="title">${item.productName}</div>
                    <div class="container">
                        <div class="row">
                            <div class="left">
                                <span>当前最低</span>
                                <span>￥6000</span>
                            </div>
                            <div class="right">
                                <span>优选评论</span>
                                <span>8266条</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="makeprice">
                    ${item.bjShop}
                </div>
                <h4>网友评论</h4>
            `
        });
        product.innerHTML = str;
    })

    let comdiv = document.createElement("div")
    let comstr = ""
    fetch("http://chst.vip:1234/api/getproductcom?productid="+cs)
    .then(body=>body.json())
    .then(res=>{
        console.log(res)
        res.result.forEach(item=>{
            comstr +=`
                    <div class="content">
                        <div class="content">
                            <div class="head">
                                <span class="id">${item.comName}</span>
                                <span class="time">${item.comTime}</span>
                            </div>
                            <div class="mid">${item.comContent}</div>
                            <div class="bot">${item.comFrom}</div>
                        </div>
                    </div>
                    `
        })
        comdiv.innerHTML=comstr;
        product.appendChild(comdiv);
    })

})